package com.kaibes.imserver.model;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.kaibes.imserver.control.UserSocketControl;
import com.kaibes.imserver.model.database.KaibesimcenterHelper;

public abstract class DealWithContacts {
	
	private UserSocketControl userSocketControl;

	public DealWithContacts(UserSocketControl userSocketControl) {
		this.userSocketControl = userSocketControl;
	}
	
	public void doit(){
		ResultSet result = KaibesimcenterHelper
				.getInstance().getContactname(
						userSocketControl
								.getUserCenterData()
								.getUsername());
		
		if (result != null) {
			try {
				while (result.next()) {
					doWhat(result);
				}

			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
	
	protected abstract void doWhat(ResultSet result);

	public UserSocketControl getUserSocketControl() {
		return userSocketControl;
	}

	public void setUserSocketControl(UserSocketControl userSocketControl) {
		this.userSocketControl = userSocketControl;
	}
	
}
